package com.tomtop.core.exception;

import com.tomtop.core._enum.CustomStatus;
import com.tomtop.core._enum.CustomStatus.LogLevel;

/**
 * 业务异常类.
 * 
 * @author Administrator
 *
 */
public class CustomException extends RuntimeException{

	private static final long serialVersionUID = 1L;
	private int code;
	private String goUrl;
	private String describe;
	private String cnmsg;
	private String details;
	private LogLevel level;
	private void init(CustomStatus customStatus){
		this.code=customStatus.code();
		this.describe=customStatus.message();
		this.goUrl=customStatus.getGoUrl();
		this.cnmsg=customStatus.cnMessage();
		this.level=customStatus.getLevel();
	}

	@Override
	public String getMessage() {
		return "异常代码:"+this.code+" 中文描述:"+this.cnmsg+"  英文描述:"+this.describe+"  详细描述:"+this.details+" 原始描述:"+super.getMessage();
	}
	
	@Override
	public String toString() {
		return this.getMessage();
	}
	
	public CustomException(CustomStatus customStatus) {
		this.init(customStatus);
	} 
	public CustomException(CustomStatus customStatus,Throwable throwable) {
		super(throwable);
		this.init(customStatus);
	} 
	public CustomException(CustomStatus customStatus,Throwable throwable,String details) {
		this(customStatus,throwable);
		this.details=details;
	} 
	public CustomException(CustomStatus customStatus, String details) {
		this(customStatus);
		this.details=details;
	} 
	public String getGoUrl() {
		return goUrl;
	}
	public int getCode() {
		return code;
	}
	public String getDescribe() {
		return describe;
	}
	public void setCode(int code) {
		this.code = code;
	}
	public String getDetails() {
		return details;
	}
	public String getCnmsg() {
		return cnmsg;
	}
	public LogLevel getLevel() {
		return level;
	}
	public void setLevel(LogLevel level) {
		this.level = level;
	}
}
